package com.ruoyi.web.controller.SteelController;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SteelTmp;
import com.ruoyi.system.service.ISteelTmpService;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Controller
 * 
 * @author ruoyi
 * @date 2025-03-02
 */
@RestController
@RequestMapping("/system/SteelTmp")
public class SteelTmpController extends BaseController {
    @Autowired
    private ISteelTmpService steelTmpService;

    /**
     * 查询列表
     */
    @PreAuthorize("@ss.hasPermi('system:SteelTmp:list')")
    @GetMapping("/list")
    public TableDataInfo list(SteelTmp steelTmp) {
        startPage();
        List<SteelTmp> list = steelTmpService.selectSteelTmpList(steelTmp);
        return getDataTable(list);
    }

    /**
     * 导出列表
     */
    @PreAuthorize("@ss.hasPermi('system:SteelTmp:export')")
    @Log(title = "", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SteelTmp SteelTmp) {
        List<SteelTmp> list = steelTmpService.selectSteelTmpList(SteelTmp);
        ExcelUtil<SteelTmp> util = new ExcelUtil<SteelTmp>(SteelTmp.class);
        util.exportExcel(response, list, "数据");
    }

    /**
     * 根据板号查询板材详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:SteelTmp:query')")
    @GetMapping(value = "/{plateNo}")
    public AjaxResult getInfo(@PathVariable("plateNo") Long plateNo) {
        return success(steelTmpService.selectSteelTmpByPlateNo(plateNo));
    }

    /**
     * 入库
     */
    @PreAuthorize("@ss.hasPermi('system:SteelTmp:add')")
    @Log(title = "入库", businessType = BusinessType.INSERT)
    @PostMapping(value = "/save")
    public AjaxResult add(@RequestBody SteelTmp steelTmp) {
        return toAjax(steelTmpService.insertSteelTmp(steelTmp));
    }

    /**
     * 更新钢材信息
     */
    @PreAuthorize("@ss.hasPermi('system:SteelTmp:edit')")
    @Log(title = "更新钢材信息", businessType = BusinessType.UPDATE)
    @PostMapping(value = "/update")
    public AjaxResult edit(@RequestBody SteelTmp steelTmp) {
        return toAjax(steelTmpService.updateSteelTmp(steelTmp));
    }

    /**
     * 批量删除钢材信息
     */
    @PreAuthorize("@ss.hasPermi('system:SteelTmp:remove')")
    @Log(title = "通过板号删除批量钢材信息", businessType = BusinessType.DELETE)
	@DeleteMapping("deleteByPlateNos")
    public AjaxResult remove(@RequestBody Long[] plateNos) {
        return toAjax(steelTmpService.deleteSteelTmpByPlateNos(plateNos));
    }

    /**
     * 根据板号查询板材详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:SteelTmp:query')")
    @PostMapping("selectSteelTmpBySteelTmpLike")
    public AjaxResult selectSteelTmpBySteelLike(@RequestBody SteelTmp steelTmp) {
        return success(steelTmpService.selectSteelTmpBySteelLike(steelTmp));
    }
}
